#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i(a);i<=(b);++i)
#define req(i,a,b) for(int i(a);i>=(b);--i)
#define sort stable_sort
using namespace std;
char buf[1<<23],*p1=buf,*p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template<typename TP> inline TP read(TP &num)
{
	TP x=0;
	int f=0;
	char ch=getchar();
	while(ch<48||ch>57) f|=ch=='-',ch=getchar();
	while(48<=ch&&ch<=57) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return num=f?-x:x;
}
template<typename ...Args> inline void read(Args &...args)
{
	(read(args),...);
}
template<typename TP> inline void write(TP x)
{
	(x<0)?(putchar('-'),x=-x):0;
	(x>9)?(write(x/10),0):0;
	putchar((x%10)^48);
}
template<typename TP> inline void writeln(TP x)
{
	write<TP>(x);
	puts("");
}
constexpr int mod=998244353;
inline int qpow(int x,int y)
{
	int res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod,y>>=1;
	}
	return res;
}
int n,x[1401],r[1401],g[1401],cnt[1403],mx,sub1=1,sub2=1;
inline int isprime(int x)
{
	if(x<2) return 0;
	if(x==2||x==3) return 1;
	if(x%2==0) return 0;
	for(int i=3;i*i<=x;i+=2) if(x%i==0) return 0;
	return 1;
}
signed main()
{
	freopen("traffic.in","r",stdin);
	freopen("traffic.out","w",stdout);
	read(n);
	rep(i,1,n) read(x[i],r[i],g[i]),x[i]%=r[i]+g[i],mx=max(mx,r[i]+g[i]),sub1&=r[i]+g[i]==r[1]+g[1],sub2&=isprime(r[i]+g[i]);
	if(!sub1&&!sub2)
	{
		int L=1;
		rep(i,1,n) L=L/__gcd(L,r[i]+g[i])*(r[i]+g[i]);
		mx=L;
	}
	rep(t,0,mx-1)
	{
		int ok=1;
		rep(i,1,n)
		{
			int tim=(x[i]+t)%(r[i]+g[i]);
			if(tim<r[i]) {++cnt[i],ok=0;break;}
		}
		if(ok) ++cnt[n+1];
	}
	rep(i,1,n+1) writeln(cnt[i]*qpow(((!sub1&&!sub2)?mx:(r[i]+g[i])),mod-2)%mod);
	return 0;
}
